package servlet;

import model.classes;
import model.teacher;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;

@WebServlet(value = "/t_seeClasses")
public class t_seeClasses extends HttpServlet{
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String username=(String) req.getSession().getAttribute("using");

        HashMap<Integer, classes> hashMap= teacher.seeClass(username);
        if(!hashMap.isEmpty()) {
            req.setAttribute("t_seeClasses",hashMap);
            req.getRequestDispatcher("/jsp/t_seeClasses.jsp").forward(req,resp);
        }
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }
}
